﻿<!--#include file="include/config.asp"-->
<!--#include file="include/conn_f.asp"-->
<!--#include file="top.asp"-->
<!--#include file="left.asp"-->
<center>
    <%
If Session("cust_id")="" Then
    Response.Write "请先登录网站!"
    Response.End
End If

Public Function OnlyNumber(StrChar)
    Const AllChar = "0123456789"
    Const AllNum = 10
    Dim ReplaceSomeChar
    Dim CharLenngth
    Dim StrChar1
    CharLenngth =  Len(StrChar)
    For j=1 To CharLenngth
        ReplaceSomeChar = Mid(StrChar,j,1)
        If InStr(AllChar,ReplaceSomeChar)<>0  Then
            If Not (ReplaceSomeChar=0 and len(StrChar1)=0) Then			
             StrChar1 =  StrChar1 & ReplaceSomeChar
            End If
        End If
    Next
    OnlyNumber = StrChar1
End Function 


' FUNCTION THAT POSTS A REQUEST TO
Function SendXml(Host,Data)
   Set xml = Server.CreateObject("Microsoft.XMLHTTP")
   xml.open "POST", Host & Data & "", false
   xml.send ""   
   'strStatus = xml.Status   
   SendXml = xml.responseText   
   Set xml = Nothing   
End Function



sql="select phone,phone_confirmed,isactive from customer where cust_id="&Session("cust_id")
Set rs=conn.execute(sql)
If Not rs.eof Then
    strPhone=rs("phone")
    phone_confirmed=rs("phone_confirmed")
    If rs("isactive")>1 Then
        Response.Write "帐号被封,无法验证!"
        Response.End
    End If
Else
    Response.Write "错误,没有此客户"
    Response.End
End If
If phone_confirmed=1 Then
    Response.Write "<font color='green'>您的电话已经验证成功,无需验证!</font>"
    Response.End
End If
If phone_confirmed=3 Then
    Response.Write "此电话:"&strphone&",之前做过验证失败了!<br />"
    Response.Write "如果您需要再试一次,请联系客户服务人员."
    Response.End
End If
strPhone = OnlyNumber(strPhone)

sql="select count(*) from phone_confirm_log where cust_id="&Session("cust_id")
Set rs=conn.execute(sql)
If Not rs.eof Then
    If  rs(0)>"2" Then
        Response.Write "You test too many times!<br />"
        Response.End
    End If
End If


sql="select cust_id from phone_confirm_log where phone_number='"&strPhone&"' and plc_status=1 "
Set rs=conn.execute(sql)
If Not rs.eof Then
    If  rs("cust_id")<>Session("cust_id") Then
        Response.Write "此电话:"&strphone&",已经激活过会员帐号,你不能用此电话激活多个会员帐号!<br />"
        Response.End
    End If
End If

Phoneleft2=left(strPhone,2)
If left(strPhone,1)<>"1" and left(strPhone,1)<>"4" Then
    If Phoneleft2<>"31" and Phoneleft2<>"32" and Phoneleft2<>"33" and Phoneleft2<>"34" and Phoneleft2<>"35" and Phoneleft2<>"36" and Phoneleft2<>"39" and Phoneleft2<>"81" and Phoneleft2<>"65" and Phoneleft2<>"61" and Phoneleft2<>"60" and Phoneleft2<>"64" and Phoneleft2<>"85" Then
        Response.Write "对不起,此国家的电话无法验证!"
        Response.End
    End If
End If
If Phoneleft2="11" or Phoneleft2="10" Then
    strPhone="1"&right(strPhone,len(strPhone)-2)
End If

'------------------------------------
' THE VERIFICATION CODE YOU WANT
' COMMENT OUT TO LET MAX MIND
' CREATE A RANDOM CODE
'------------------------------------
randomize
strVCode = int(Rnd*9000)+1000
Session("strVCode")=strVCode

strLic = "1yI6AqYf1rwa"
strHost = "https://www.maxmind.com/app/telephone_http"

strData = "?l=" & strLic & "&phone=%2B" & strPhone
If Not strVCode = "" Then
   strData = strData & "&verify_code=" &strVCode	'&"&language=Chinese"
End If

Response.Write "填您的电话号码是:00"&strPhone
    %>
    <br />
    请确保您的电话畅通,你几分钟内会接到一个电话.<br />
    请耐心等待几分钟,不要重复提交电话验证请求.<br />
    <br />
    如果您没有接到电话,请检查一下您的电话格式是否正确.<br />
    您的电话号码前必须有国家代码,美国加拿大用户为001<br />
    中国的手机号码无法接到电话,所以无法激活.<br />
    <%
strResult = SendXml(strHost, strData)
strRefId = Split(Split(strResult, ";")(0), "=")(1)
sql="update customer set phone_confirmed=2 where cust_id="&Session("cust_id")
conn.execute sql

sql="insert into phone_confirm_log(cust_id,phone_number,vercode,ref_id,confirm_time) "
sql=sql&"values("&Session("cust_id")&",'"&strphone&"','"&strVCode&"','"&strRefId&"',now())"
conn.execute sql
sql="select LAST_INSERT_ID() from phone_confirm_log"
Set rs2=conn.execute(sql)
pcl_id=rs2(0)

If Not strResult = "" and InStr(strResult, "err") = 0 Then    
    %>
    <br />
    请把电话中报给您的4个数字填在下面:<br />
    <form action="telver2.asp">
    <input name="pcl_id" value="<%=pcl_id%>" type="hidden">
    我电话中听到的4个数字是:<input name="strVcode2" size="4" maxlength="4"><br />
    <input type="submit" value="提交">
    </form>
    <br />
    <%
Else
    %>
    <br />
    您输入的电话号码格式不对!<br />
    您的电话号码前必须有国家代码,美国加拿大用户为001<br />
    中国的手机号码无法接到电话,所以无法激活.<br />
    <%
End If
 

    %>
</center>

<!--#include file="bottom.asp"-->
